package com.sx.zongzhi.presenter;

import com.sx.zongzhi.MyApplication;
import com.sx.zongzhi.bean.KeyAreaDetailBean;
import com.sx.zongzhi.modle.ApiManager;
import com.sx.zongzhi.net.BaseCallBack;
import com.sx.zongzhi.net.BaseResult;
import com.sx.zongzhi.view.IKeyAreaDetailView;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by XZY on 2017/11/30.
 *获取重点区域详情
 */
public class KeyAreaDetailPest {

    private IKeyAreaDetailView detailView;

    public KeyAreaDetailPest(IKeyAreaDetailView detailView) {
        this.detailView=detailView;
    }


    /**
     * 获取详情
     * @param id 重点区域id
     */
    public void getKeyAreaList(String id){
        Map<String,Object> map=new HashMap<>();
        map.put("sid", MyApplication.sid);
        map.put("id", id);
        new ApiManager().getKeyAreaDetail(map, new BaseCallBack<BaseResult<KeyAreaDetailBean>>() {
            @Override
            public void onSuccess(BaseResult<KeyAreaDetailBean> response) {
                detailView.getKeyAreaDetail(response.getData());
            }
            @Override
            public void onFailures(String message) {
                detailView.showError(message);
            }
        });
    }

    /**
     * 删除
     * @param id 重点区域id
     */
    public void KeyAreaDelete(String id){
        Map<String,Object> map=new HashMap<>();
        map.put("sid", MyApplication.sid);
        map.put("id", id);
        new ApiManager().KeyAreaDelete(map, new BaseCallBack<BaseResult<Boolean>>() {
            @Override
            public void onSuccess(BaseResult<Boolean> response) {
                detailView.KeyAreaDelete("删除成功");
            }
            @Override
            public void onFailures(String message) {
                detailView.showError(message);
            }
        });
    }

}
